//
//  STStatusToolBarView.m
//  OCVVeibo
//
//  Created by leergou on 16/7/27.
//  Copyright © 2016年 WhiteHouse. All rights reserved.
//

#import "STStatusToolBarView.h"
#import "STStatusVM.h"

@interface STStatusToolBarView ()


/**
 timeline_icon_retweet
 timeline_icon_comment
 timeline_icon_unlike
 */
/** 底部按钮 */
@property (nonatomic,strong) UIButton *retweetButton;
@property (nonatomic,strong) UIButton *commentButton;
@property (nonatomic,strong) UIButton *unlikeButton;
/** 分割线 */
@property (nonatomic,strong) UIImageView *leftLine;
@property (nonatomic,strong) UIImageView *rightLine;
@end

@implementation STStatusToolBarView

- (instancetype)init{
    
    if (self = [super init]) {
        
        [self setupUI];
    }
    return self;
}

#pragma mark - 按钮点击方法
- (void)buttonClick:(UIButton *)sender{
    
    NSLog(@"点击了");
}

#pragma mark - 设置视图
- (void)setupUI{
    self.backgroundColor = [UIColor whiteColor];
    
    // 添加子控件
    self.commentButton = [self addButton:@"评论" image:@"timeline_icon_comment"];
    self.retweetButton = [self addButton:@"转发" image:@"timeline_icon_retweet"];
    self.unlikeButton = [self addButton:@"赞" image:@"timeline_icon_unlike"];
    self.leftLine = [self addLine];
    self.rightLine = [self addLine];
    
    // 添加约束
    [self.commentButton makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.leading.equalTo(self);
        make.width.equalTo(self.retweetButton);
    }];

    [self.retweetButton makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.commentButton.trailing);
        make.top.bottom.equalTo(self);
        make.width.equalTo(self.unlikeButton);
    }];
    
    [self.unlikeButton makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.retweetButton.trailing);
        make.top.bottom.trailing.equalTo(self);
    }];
    
    [self.leftLine makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.commentButton.trailing);
        make.centerY.equalTo(self);
    }];
    
    [self.rightLine makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.retweetButton.trailing);
        make.centerY.equalTo(self);
    }];
}

#pragma mark - 创建分割线方法
- (UIImageView *)addLine{
    
    UIImageView *lineView = [[UIImageView alloc] initWithNormalImage:@"timeline_card_bottom_line" highlightedImage:@"timeline_card_bottom_line_highlighted"];
    [self addSubview:lineView];
    return lineView;
}

#pragma mark - 创建底部按钮的方法
- (UIButton *)addButton:(NSString *)title image:(NSString *)imageName{
    
    UIButton *button = [[UIButton alloc] initWithTitle:title bgNorImg:@"timeline_card_bottom_background" bgHighImg:@"timeline_card_bottom_background_highlighted" highlightedImg:nil normalImg:imageName selectedImg:nil target:self action:@selector(buttonClick:)];
    [button setTitleColor:[UIColor darkGrayColor] forState:(UIControlStateNormal)];
    [self addSubview:button];
    return button;
}


@end
